package com.google.android.hello;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
//import android.widget.TextView;
import android.util.Log;
import android.view.KeyEvent;

public class HelloAndroid extends Activity {
	long m_dwSplashTime = 3000;
    boolean m_bPaused = false;    
    boolean m_bSplashActive = true;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //TextView tv = new TextView(this);
        //tv.setText("hello Android zhaoqun");
        //Draw the splash screen
        setContentView(R.layout.splash);//R.layout.main
        //time thread
        //history test
        Thread splashTimer = new Thread(){
        	public void run(){
        		try{
        			//wait loop
        			long ms = 0;
        			while(m_bSplashActive && ms < m_dwSplashTime){
        				sleep(100);
        				//advance the timer only if we're running
        				if(!m_bPaused)
        					ms += 100;
        			}
        			//advance to next screen
        			System.out.println("ok1");
        			startActivity(new Intent("com.google.app.hello.CLEARSPLASH"));
        		}
        		catch (Exception e) {
					// TODO: handle exception
        			Log.e("splash", e.toString());
				}
        		finally{
        			finish();
        		}
        	}        	
        };
        splashTimer.start();
        System.out.println("ok2");
    } 
    
    public boolean onKeyDown(int keyCode, KeyEvent event){
    	//if we get any key, clear the splash screen
    	super.onKeyDown(keyCode, event);
    	m_bSplashActive = false;
    	return true;
    } 
    
    protected void onStart(){
    	super.onStart();
    }
    
    protected void onResume(){
    	super.onResume();
    	m_bPaused = false;
    }
//startActivity will run    
    protected void onPause(){
    	super.onPause();
    	m_bPaused = true;
    }
    
    protected void onStop(){
    	super.onStop();
    }
    
    protected void onDestroy(){
    	super.onDestroy();
    }
}